var colors = ['#9bdafe', '#8468ff', '#fe9a7f'];

var myChart01 = echarts.init(document.getElementById('myChart01'));

var option01 = {
		title: {
	        text: '各模块数据访问量'
		},
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: ['访问量(次数)'],
            bottom: "25px",
            textStyle: {
                color: '#333',
            },
            top:26,
            right:18,
        },
        grid: {
            // show:true,
            top: 90,
            bottom:90,
            left:55,
            right:20,
        },
       
        xAxis: {
            type: 'category',
            data:[],
            axisLine: {
                lineStyle: {
                    color: "#5095ff",
                    width:2,
                }
            },
            axisTick: {
                inside: false,
                length: 5,
            },
            axisLabel: {
                interval:0,
                rotate:25,
                textStyle: {
                    color: '#333',
                    fontSize:12,
                },
                margin:12,
            }
        },
        yAxis: {
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: "#fff"
                }
            },
            axisTick: {
                show: false,
                inside: true,
                length: 5,
            },
            axisLabel: {
                textStyle: {
                    color: '#333',
                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#e4e4e4',
                }
            },
        },
  
        series: [{
            name: '访问量(次数)',
            type: 'bar',
            markPoint:{
                symbol:'rect',
            },
             markPoint:{
                symbol:'rect',
            },
            barWidth:6,
            smooth: true,
            data: [],
            itemStyle: {normal: {color: colors[0],}},
            showSymbol: false,
        }]  
    };

myChart01.setOption(option01);

function indexFormatter(value, row, index) {
	options = $("#logListData").bootstrapTable("getOptions");
	rowStart = (options.pageNumber - 1) * options.pageSize;
	return rowStart + index + 1;
}
 
 
/**
 * @description 查询条件与分页数据
 * @time
 */
function queryParams(params) {
	
	var temp = {
			pageNum : params.offset / params.limit + 1,
			pageSize: params.limit,
			district : $("#district").val(),  
			module : $("#module").val(),  
			accessUser : $("#accessUser").val() 
	};
	
	/*if (pageReqeust.limit) {
		// 当前页码
		pageReqeust.pageNum = pageReqeust.offset / pageReqeust.limit + 1;
	} else {
		pageReqeust.limit = 0; // 导出所有
	}*/
	
//	console.log(temp);
	
	return temp;
}
function getSelectIds(){
 	var data = $("#userListData").bootstrapTable('getSelections');
 	var ids =new Array();
 	if(data.length>=1){
 		for(var i=0;i<data.length;i++){	
 			ids.push(data[i].id);
 		}
    }	
 	return ids;
 }

function loadLogStatData(myChart,option){
   var district = $("#district").val();  
   var accessDate = $("#accessDate").val();
   var districtName = $("#district").find("option:selected").text(); 
   if(district == null || district == ''){
	   districtName = "全国";
   }
	$.ajax({
		type : "post",
		url : basePath+"/log/getLogStat",
		dataType : "text",
		data : {district:district,accessDate:accessDate},
		//后台所需要的参数
		success : function(data) {
			if(data != null){
				var splits = data.split("|");
				var totalpv = splits[0];
				
				$("#pvlable").text(districtName+"全网数据访问量"+totalpv);
				
				var pvdata = JSON.parse(splits[1]);
				
				var modules=[];
				var pvcount=[];
				for(var i=0;i<pvdata.length;i++){
					modules[i]=pvdata[i].moduleName;
					pvcount[i]=pvdata[i].pvCount;
				}
				
				option01.xAxis.data=modules;
				option01.series[0].data=pvcount;
				myChart01.setOption(option01);
			}
		}
	});
}

!function(e, t, o) {
	"use strict";
	!function() {
	
	}()
}(document, window, jQuery);


$(function () {  
    $('#datetimepicker1').datetimepicker({  
        format: 'YYYY-MM-DD',  
        locale: moment.locale('zh-cn')  
    });  
    
    
	 //查询按钮事件  
    $("#searchBtn").off().on("click",function(){  
//        var district = $("#district").val();  
//        var accessDate = $("#accessDate").val();
//        $("#district").find("option:selected").text(); 
        loadLogStatData(myChart01,option01);
        
    });  
    
    //重置按钮事件  
    $("#resetBtn").off().on("click",function(){  
        $("#accessDate").val(""); 
        document.getElementById("district").options.selectedIndex = 0; //回到初始状态
        document.getElementById("module").options.selectedIndex = 0;
    })
    
  
    loadLogStatData(myChart01,option01);
});  
